package com.wen.pojo;

import com.wen.utils.DateUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * (Orders)实体类
 *
 * @author makejava
 * @since 2021-02-16 17:30:14
 */


@Data
@AllArgsConstructor
@NoArgsConstructor
public class Orders implements Serializable {
    private static final long serialVersionUID = 156052469452068884L;
    /**
     * 无意义，主键id
     */

    private Integer id;

    /**
     * 订单编号
     */

    private String orderNum;

    /**
     * 下单时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date orderTime;
    private String orderTimeStr;
    /**
     * 产品信息
     */
    private Product product;
    /**
     * 游客信息
     */
    private List<Traveller> travellers;
    /**
     * 会员信息
     */
    private Member member;
    /**
     * 出行人数
     */

    private Integer peopleCount;

    /**
     * 订单描述(其他信息)
     */

    private String orderDesc;

    /**
     * 支付方式(0 支付宝 1微信 2其他)
     */

    private Integer payType;
    private String payTypeStr;
    /**
     * 订单状态(0未支付 1已支付)
     */

    private Integer orderStatus;
    private String orderStatusStr;

    public String getOrderTimeStr() {
        if (orderTime != null) {
            orderTimeStr = DateUtils.date2String(orderTime, "yyyy-MM-dd HH:mm:ss");
        }
        return orderTimeStr;
    }

    public String getPayTypeStr() {
        if (payType == 0) {
            payTypeStr = "支付宝";
        } else if (payType == 1) {
            payTypeStr = "微信";
        } else {
            payTypeStr = "其他";
        }
        return payTypeStr;
    }

    public String getOrderStatusStr() {
        if (orderStatus == 0) {
            orderStatusStr = "未支付";
        } else {
            orderStatusStr = "已支付";
        }
        return orderStatusStr;
    }


    /**
     * 产品id外键
     */

    private Integer productId;

    /**
     * 会员(联系人)id外键
     */

    private Integer memberId;


}